﻿using Basic.FormGatewaryModular.Interface;
using Basic.FormRemoteModel.PhysicalGroup;
using Basic.FormRemoteModel.PhysicalGroup.Model;
using WeDonekRpc.Client;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Services
{
    internal class PhysicaGroupService : IPhysicaGroupService
    {

        public long Add ( PhysicalGroupSet obj )
        {
            return new AddPhysicalGroup
            {
                Datum = obj,
            }.Send();
        }

        public void Delete ( long id )
        {
            new DeletePhysicalGroup
            {
                Id = id
            }.Send();
        }

        public PhyGroupData Get ( long id )
        {
            return new GetPhysicalGroup
            {
                Id = id
            }.Send();
        }

        public PhyGroupItem[] GetEnables ()
        {
            return new GetPhysicalGroupItems().Send();
        }

        public PagingResult<PhyGroupDto> Query ( PagingParam<PhysicalGroupQuery> query )
        {
            return new QueryPhysicalGroup
            {
                Index = query.Index,
                Size = query.Size,
                SortName = query.SortName,
                IsDesc = query.IsDesc,
                NextId = query.NextId,
                Query = query.Query,
            }.Send();
        }

        public bool Set ( long id, PhysicalGroupSet obj )
        {
            return new SetPhysicalGroup
            {
                Datum = obj,
                Id = id
            }.Send();
        }

        public void SetIsEnable ( long id, bool isEnable )
        {
            new SetPhysicalGroupIsEnable
            {
                Id = id,
                IsEnable = isEnable
            }.Send();
        }
    }
}
